<template>
  <div>
    <!-- 传递数据； -->
    <v-header :seller="seller">
       
    </v-header>
    <div class="tab border-1px">
        <div class="tab-item">
           <router-link to="/goods">商品</router-link>
        </div>
        <div class="tab-item">
           <router-link to="/ratings">评论</router-link>
        </div>
        <div class="tab-item">
           <router-link to="/seller">商家</router-link>
        </div>
    </div>
    <!-- 切换路由刷新的是router-view中的内容,把seller传递进good组件: -->
     <router-view :seller="seller"></router-view>

  </div>
</template>

<script>
import header from './components/header/header.vue';
// 存储常量判断状态
const ERR_OK=0;
export default {
  data(){
     return{
       seller:{}
     };
  },
  name: 'App',
  created(){
    this.$http.get('/api/seller').then(function(res){
     
      // 调用它的json方法拿到数据
      res=res.body;
      if(res.errno===ERR_OK){
        this.seller=res.data;
        console.log(this.seller);
        // 把获取到数据给header组件
      }
    })
  },
  components:{
    'v-header':header
  }
}
</script>

<style lang="less">
@import "./common/less/mixin.less";
.tab{
  display: flex;
  flex-direction:row;
  align-items:space-between;
  height: 40px;
  line-height: 40px;
  position: relative;
  .border-1px(#e5e5e5);
  .tab-item{
    flex:1;
    text-align: center;
    color:#4d555d;
    font-size: 14px;
    cursor: pointer;
    &>a{
      display: block;
      &.active{
        color:#f01414;
      }
    }
  }
}
</style>
